package com.hnevc.trafficdemotest1.fragment.dataanalsys;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hnevc.trafficdemotest1.R;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class DataAnalsysFragment extends Fragment {

    List<Fragment> mFragmentList;
    ViewPager mViewPager;
    public DataAnalsysFragment() {
        // Required empty public constructor
        mFragmentList = new ArrayList<>();
        mFragmentList.add(new DataAnalsysFragment1());
        mFragmentList.add(new DataAnalsysFragment2());
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_data_analsys, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mViewPager = (ViewPager) getView().findViewById(R.id.id_view_pager);
        mViewPager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager()));


    }
    class  MyFragmentPagerAdapter extends FragmentPagerAdapter{

        public MyFragmentPagerAdapter(FragmentManager fm) {
            super(fm);

        }

        @Override
        public Fragment getItem(int position) {
            return mFragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mFragmentList.size();
        }
    }
}
